#pragma once

#include <string>
#include <fstream>
#include <sstream>
#include <vector>
#include "Shapefile.h"
#include "gdal.h"
#include "gdal_priv.h"
#include "cpl_port.h"

#include "easytools.h"
#include "stringFuncs.h"
#include "UdxDataApi.h"

using namespace std;

namespace UDXConvertion
{
	enum DataFormat
	{
		TABLE = 0,
		SHAPE,
		POINT_CLOUD,
		TIN,
		GRID,
		OPTIONS,
		TABLE_LIST,
		SHAPE_LIST,
		POINT_CLOUD_LIST,
		TIN_LIST,
		GRID_LIST
	};

	class EXPORT_UDXCONVERT_API UDX2Input
	{
	public:
		UDX2Input(void);
		UDX2Input(string,string,DataFormat);
		~UDX2Input(void);
		bool Convert();
		int getDataCount();
		string getOutputPaths();
	private:
		std::string oPath,iPath,oPaths;
		DataFormat dataFormat;
		int dataCount;

		bool UDXNode2Table(string,NGIS::Data::IUdxNode*);
		bool UDX2Table();
		bool UDX2Tables();

		bool UDX2Shp();
		bool UDX2Shps();

		bool UDX2SPC();
		bool UDX2SPCs();

		bool UDXNode2GTiff(NGIS::Data::IUdxNode*,string);
		bool UDX2Grid();
		bool UDX2Grids();

		bool UDX2Options();
	};

	class EXPORT_UDXCONVERT_API Output2UDX
	{
	public:
		Output2UDX(void);
		Output2UDX(string,string,DataFormat);
		~Output2UDX(void);
		bool Convert();
	private:
		std::string iPath,oPath;
		DataFormat dataFormat;

		bool table2UDXNode(string,NGIS::Data::IUdxNode*);
		bool table2UDX();
		bool tables2UDX();

		bool shp2UDX();
		bool shps2UDX();

		bool spc2UDX();
		bool spcs2UDX();

		NGIS::Data::IUdxDataset* gtiff2UDXNode(string);
		bool gtiff2Stream(string,string&);
		bool grid2UDX();
		bool grids2UDX();

		bool options2UDX();
	};
}

